package com.qianfeng.dao.impl;

import java.util.List;

import com.qianfeng.commons.DBUtils;
import com.qianfeng.dao.IAddressDao;
import com.qianfeng.entity.Address;

public class AddressDaoImpl extends DBUtils<Address> implements IAddressDao {

	@Override
	public List<Address> getAddressListByUserId(int userid) {
		
		String sql = "select * from t_address where userid = ?";
		return super.getList(sql, Address.class, userid);
	}

	@Override
	public boolean addAdd(Address ad) {
		String sql="insert into t_address values(null,?,?,?,?,?)";
		int i = super.commonOper(sql, ad.getShouhuoren(),ad.getPhone(),ad.getAddress(),ad.getUserid(),ad.getIsdefault());
		if(i>0){
			return true;
		}
		return false;
	}

	@Override
	public void update(Address address2) {
		String sql="update t_address set isdefault = ? where id =?";
		super.commonOper(sql, address2.getIsdefault(),address2.getId());
	}

}
